import { Injectable } from '@angular/core';
import { MessageSelector } from '@shared/lib/store/message/message.selector';
import { Store } from '@ngxs/store';
import { ShopAction } from '@shop/store/shop.action';

@Injectable({
  providedIn: 'root',
})
export class ShopService {

  constructor(
      private store: Store,
  ) {
  }

  init() {
    this.store.select(MessageSelector.msg).subscribe(r => {
      if (!r) return;
      if ('Logistics_BillCallback' === r.key) this.store.dispatch([new ShopAction.ClearCart()]);
    });
  }

}
